import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default {
  state: {
    hasRoute: false,
    menuList: [],
    permList: [],
    editableTabsValue: 'Index',
    editableTabs: [{
      title: '首页',
      name: 'Index',
    },
    ],
  },
  mutations: {
    setMenuList: (state, menus) => {
      state.menuList = menus
    },
    setPermList(state, authoritys) { 
      state.permList = authoritys 
    },
    addTab(state, tab) {
      let index = state.editableTabs.findIndex(editableTab => editableTab.name === tab.name)
      if (index < 0) {
        state.editableTabs.push({
          title: tab.title,
          name: tab.name,
        });
      }
      state.editableTabsValue = tab.name
    },
  },
  actions: {
  }
}